/* 
 * File:   EditarCampania.h
 * Author: agu
 *
 * Created on 22 de junio de 2014, 2:43
 */

#ifndef EDITARCAMPANIA_H
#define	EDITARCAMPANIA_H
#include <gtkmm-3.0/gtkmm.h>
#include <vector>
#include <string>
#include "editor_ListadoNiveles.h"
#include "editor_Nivel.h"
#include "editor_Campaign.h"
#include "common_ParserXML.h"
using std::string;
using std::vector;

class EditarCampania : public Gtk::Window {
public:
    EditarCampania();
    void run();
    void setWindowsBack(Gtk::Window *windowBack);
    void setCampaignName(const string name);
    virtual ~EditarCampania();
private:
    void loadWidgets();
    void connectWidgets();
    void close();
    void back();
    void levelsList();
    void save();
    void cancel();
    void saveExit();
    void incrementPlayers();
    void incrementLevels();
    void onComboDifChanged();
    void onComboImageChanged();
    void loadCampaignInfo();
    void getCampaignInfo();
    void hideMessageError();
    Glib::RefPtr<Gtk::Builder> builder;
    Gtk::Window* window;
    Gtk::Button *buttonLevels, *buttonBack, *buttonSave, *buttonOk,*buttonOk2, *buttonCancel;
    Gtk::Entry* entryName;
    Gtk::ComboBox *comboImage, *comboDif;
    Gtk::SpinButton *spinTotalPlayers, *spinTotalLevels;
    Gtk::MessageDialog *message,*messageError;
    Gtk::Image* image;
    ListadoNiveles listLevels;
    Campaign campaign;
    ParserXML parserXML;
    string campaignName;
    vectorS capaignInfo;
    vector< vector<string> > levelsInfo;
    
    //Tree model columns:

    class ModelColumnsDiff : public Gtk::TreeModel::ColumnRecord {
    public:

        ModelColumnsDiff() {
            add(colDiffName);
        }
        Gtk::TreeModelColumn<Glib::ustring> colDiffName;
    };
    //Tree model columns:

    class ModelColumnsImages : public Gtk::TreeModel::ColumnRecord {
    public:

        ModelColumnsImages() {
            add(colImageName);
        }
        Gtk::TreeModelColumn<Glib::ustring> colImageName;
    };
    ModelColumnsDiff columnsDiff;
    ModelColumnsImages columnsImages;
    Glib::RefPtr<Gtk::ListStore> refTreeModelDiff;
    Glib::RefPtr<Gtk::ListStore> refTreeModelImages;
    void createModel();
    void createModelDiff();
    void createModelImages();
    void loadImageDirectory(Gtk::TreeModel::Row row);
    vector<Nivel> levels;
};

#endif	/* EDITARCAMPANIA_H */

